package c.e.a.b.f.b;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Parcelable.Creator;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;
import b.i.b.f;
import c.e.a.b.b.j.c;
import c.e.a.b.e.c.a1;
import c.e.a.b.e.c.e1;
import c.e.a.b.e.c.e1.a;
import c.e.a.b.e.c.fa;
import c.e.a.b.e.c.l0;
import c.e.a.b.e.c.o0;
import c.e.a.b.e.c.q8;
import c.e.a.b.e.c.u4;
import com.google.android.gms.measurement.internal.zzaq;
import com.google.android.gms.measurement.internal.zzku;
import com.google.android.gms.measurement.internal.zzz;
import com.huawei.hms.jos.games.ranking.RankingConst;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */
public final class g extends i9 {
    public static final String[] f = new String[]{"last_bundled_timestamp", "ALTER TABLE events ADD COLUMN last_bundled_timestamp INTEGER;", "last_bundled_day", "ALTER TABLE events ADD COLUMN last_bundled_day INTEGER;", "last_sampled_complex_event_id", "ALTER TABLE events ADD COLUMN last_sampled_complex_event_id INTEGER;", "last_sampling_rate", "ALTER TABLE events ADD COLUMN last_sampling_rate INTEGER;", "last_exempt_from_sampling", "ALTER TABLE events ADD COLUMN last_exempt_from_sampling INTEGER;", "current_session_count", "ALTER TABLE events ADD COLUMN current_session_count INTEGER;"};
    public static final String[] g = new String[]{"origin", "ALTER TABLE user_attributes ADD COLUMN origin TEXT;"};
    public static final String[] h = new String[]{"app_version", "ALTER TABLE apps ADD COLUMN app_version TEXT;", "app_store", "ALTER TABLE apps ADD COLUMN app_store TEXT;", "gmp_version", "ALTER TABLE apps ADD COLUMN gmp_version INTEGER;", "dev_cert_hash", "ALTER TABLE apps ADD COLUMN dev_cert_hash INTEGER;", "measurement_enabled", "ALTER TABLE apps ADD COLUMN measurement_enabled INTEGER;", "last_bundle_start_timestamp", "ALTER TABLE apps ADD COLUMN last_bundle_start_timestamp INTEGER;", "day", "ALTER TABLE apps ADD COLUMN day INTEGER;", "daily_public_events_count", "ALTER TABLE apps ADD COLUMN daily_public_events_count INTEGER;", "daily_events_count", "ALTER TABLE apps ADD COLUMN daily_events_count INTEGER;", "daily_conversions_count", "ALTER TABLE apps ADD COLUMN daily_conversions_count INTEGER;", "remote_config", "ALTER TABLE apps ADD COLUMN remote_config BLOB;", "config_fetched_time", "ALTER TABLE apps ADD COLUMN config_fetched_time INTEGER;", "failed_config_fetch_time", "ALTER TABLE apps ADD COLUMN failed_config_fetch_time INTEGER;", "app_version_int", "ALTER TABLE apps ADD COLUMN app_version_int INTEGER;", "firebase_instance_id", "ALTER TABLE apps ADD COLUMN firebase_instance_id TEXT;", "daily_error_events_count", "ALTER TABLE apps ADD COLUMN daily_error_events_count INTEGER;", "daily_realtime_events_count", "ALTER TABLE apps ADD COLUMN daily_realtime_events_count INTEGER;", "health_monitor_sample", "ALTER TABLE apps ADD COLUMN health_monitor_sample TEXT;", "android_id", "ALTER TABLE apps ADD COLUMN android_id INTEGER;", "adid_reporting_enabled", "ALTER TABLE apps ADD COLUMN adid_reporting_enabled INTEGER;", "ssaid_reporting_enabled", "ALTER TABLE apps ADD COLUMN ssaid_reporting_enabled INTEGER;", "admob_app_id", "ALTER TABLE apps ADD COLUMN admob_app_id TEXT;", "linked_admob_app_id", "ALTER TABLE apps ADD COLUMN linked_admob_app_id TEXT;", "dynamite_version", "ALTER TABLE apps ADD COLUMN dynamite_version INTEGER;", "safelisted_events", "ALTER TABLE apps ADD COLUMN safelisted_events TEXT;", "ga_app_id", "ALTER TABLE apps ADD COLUMN ga_app_id TEXT;"};
    public static final String[] i = new String[]{"realtime", "ALTER TABLE raw_events ADD COLUMN realtime INTEGER;"};
    public static final String[] j = new String[]{"has_realtime", "ALTER TABLE queue ADD COLUMN has_realtime INTEGER;", "retry_count", "ALTER TABLE queue ADD COLUMN retry_count INTEGER;"};
    public static final String[] k;
    public static final String[] l;
    public static final String[] m = new String[]{"previous_install_count", "ALTER TABLE app2 ADD COLUMN previous_install_count INTEGER;"};
    public final h d = new h(this, this.a.a, "google_app_measurement.db");
    public final e9 e = new e9(this.a.n);

    static {
        String str = "session_scoped";
        k = new String[]{str, "ALTER TABLE event_filters ADD COLUMN session_scoped BOOLEAN;"};
        l = new String[]{str, "ALTER TABLE property_filters ADD COLUMN session_scoped BOOLEAN;"};
    }

    public g(k9 k9Var) {
        super(k9Var);
    }

    public static void G(ContentValues contentValues, String str, Object obj) {
        f.N(str);
        Objects.requireNonNull(obj, "null reference");
        if (obj instanceof String) {
            contentValues.put(str, (String) obj);
        } else if (obj instanceof Long) {
            contentValues.put(str, (Long) obj);
        } else if (obj instanceof Double) {
            contentValues.put(str, (Double) obj);
        } else {
            throw new IllegalArgumentException("Invalid value type");
        }
    }

    public final Object A(Cursor cursor, int i) {
        int type = cursor.getType(i);
        if (type == 0) {
            d().f.a("Loaded invalid null value from database");
            return null;
        } else if (type == 1) {
            return Long.valueOf(cursor.getLong(i));
        } else {
            if (type == 2) {
                return Double.valueOf(cursor.getDouble(i));
            }
            if (type == 3) {
                return cursor.getString(i);
            }
            if (type != 4) {
                d().f.b("Loaded invalid unknown value type, ignoring it", Integer.valueOf(type));
                return null;
            }
            d().f.a("Loaded invalid blob type value, ignoring it");
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:20:0x004b  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x0053  */
    public final java.lang.String B(long r5) {
        /*
        r4 = this;
        r4.g();
        r4.n();
        r0 = 0;
        r1 = r4.t();	 Catch:{ SQLiteException -> 0x003c, all -> 0x003a }
        r2 = "select app_id from apps where app_id in (select distinct app_id from raw_events) and config_fetched_time < ? order by failed_config_fetch_time limit 1;";
        r3 = 1;
        r3 = new java.lang.String[r3];	 Catch:{ SQLiteException -> 0x003c, all -> 0x003a }
        r5 = java.lang.String.valueOf(r5);	 Catch:{ SQLiteException -> 0x003c, all -> 0x003a }
        r6 = 0;
        r3[r6] = r5;	 Catch:{ SQLiteException -> 0x003c, all -> 0x003a }
        r5 = r1.rawQuery(r2, r3);	 Catch:{ SQLiteException -> 0x003c, all -> 0x003a }
        r1 = r5.moveToFirst();	 Catch:{ SQLiteException -> 0x0038 }
        if (r1 != 0) goto L_0x0030;
    L_0x0021:
        r6 = r4.d();	 Catch:{ SQLiteException -> 0x0038 }
        r6 = r6.n;	 Catch:{ SQLiteException -> 0x0038 }
        r1 = "No expired configs for apps with pending events";
        r6.a(r1);	 Catch:{ SQLiteException -> 0x0038 }
        r5.close();
        return r0;
    L_0x0030:
        r6 = r5.getString(r6);	 Catch:{ SQLiteException -> 0x0038 }
        r5.close();
        return r6;
    L_0x0038:
        r6 = move-exception;
        goto L_0x003e;
    L_0x003a:
        r6 = move-exception;
        goto L_0x0051;
    L_0x003c:
        r6 = move-exception;
        r5 = r0;
    L_0x003e:
        r1 = r4.d();	 Catch:{ all -> 0x004f }
        r1 = r1.f;	 Catch:{ all -> 0x004f }
        r2 = "Error selecting expired configs";
        r1.b(r2, r6);	 Catch:{ all -> 0x004f }
        if (r5 == 0) goto L_0x004e;
    L_0x004b:
        r5.close();
    L_0x004e:
        return r0;
    L_0x004f:
        r6 = move-exception;
        r0 = r5;
    L_0x0051:
        if (r0 == 0) goto L_0x0056;
    L_0x0053:
        r0.close();
    L_0x0056:
        throw r6;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.B(long):java.lang.String");
    }

    /* JADX WARNING: Removed duplicated region for block: B:34:0x00ad  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00b5  */
    public final java.util.List<c.e.a.b.f.b.u9> C(java.lang.String r14) {
        /*
        r13 = this;
        b.i.b.f.N(r14);
        r13.g();
        r13.n();
        r0 = new java.util.ArrayList;
        r0.<init>();
        r1 = 0;
        r2 = r13.t();	 Catch:{ SQLiteException -> 0x007e, all -> 0x007c }
        r3 = "user_attributes";
        r4 = "name";
        r5 = "origin";
        r6 = "set_timestamp";
        r7 = "value";
        r4 = new java.lang.String[]{r4, r5, r6, r7};	 Catch:{ SQLiteException -> 0x007e, all -> 0x007c }
        r5 = "app_id=?";
        r11 = 1;
        r6 = new java.lang.String[r11];	 Catch:{ SQLiteException -> 0x007e, all -> 0x007c }
        r12 = 0;
        r6[r12] = r14;	 Catch:{ SQLiteException -> 0x007e, all -> 0x007c }
        r7 = 0;
        r8 = 0;
        r9 = "rowid";
        r10 = "1000";
        r2 = r2.query(r3, r4, r5, r6, r7, r8, r9, r10);	 Catch:{ SQLiteException -> 0x007e, all -> 0x007c }
        r3 = r2.moveToFirst();	 Catch:{ SQLiteException -> 0x007a }
        if (r3 != 0) goto L_0x003d;
    L_0x0039:
        r2.close();
        return r0;
    L_0x003d:
        r7 = r2.getString(r12);	 Catch:{ SQLiteException -> 0x007a }
        r3 = r2.getString(r11);	 Catch:{ SQLiteException -> 0x007a }
        if (r3 != 0) goto L_0x0049;
    L_0x0047:
        r3 = "";
    L_0x0049:
        r6 = r3;
        r3 = 2;
        r8 = r2.getLong(r3);	 Catch:{ SQLiteException -> 0x007a }
        r3 = 3;
        r10 = r13.A(r2, r3);	 Catch:{ SQLiteException -> 0x007a }
        if (r10 != 0) goto L_0x0066;
    L_0x0056:
        r3 = r13.d();	 Catch:{ SQLiteException -> 0x007a }
        r3 = r3.f;	 Catch:{ SQLiteException -> 0x007a }
        r4 = "Read invalid user property value, ignoring it. appId";
        r5 = c.e.a.b.f.b.q3.s(r14);	 Catch:{ SQLiteException -> 0x007a }
        r3.b(r4, r5);	 Catch:{ SQLiteException -> 0x007a }
        goto L_0x0070;
    L_0x0066:
        r3 = new c.e.a.b.f.b.u9;	 Catch:{ SQLiteException -> 0x007a }
        r4 = r3;
        r5 = r14;
        r4.m1502init(r5, r6, r7, r8, r10);	 Catch:{ SQLiteException -> 0x007a }
        r0.add(r3);	 Catch:{ SQLiteException -> 0x007a }
    L_0x0070:
        r3 = r2.moveToNext();	 Catch:{ SQLiteException -> 0x007a }
        if (r3 != 0) goto L_0x003d;
    L_0x0076:
        r2.close();
        return r0;
    L_0x007a:
        r0 = move-exception;
        goto L_0x0080;
    L_0x007c:
        r14 = move-exception;
        goto L_0x00b3;
    L_0x007e:
        r0 = move-exception;
        r2 = r1;
    L_0x0080:
        r3 = r13.d();	 Catch:{ all -> 0x00b1 }
        r3 = r3.f;	 Catch:{ all -> 0x00b1 }
        r4 = "Error querying user properties. appId";
        r5 = c.e.a.b.f.b.q3.s(r14);	 Catch:{ all -> 0x00b1 }
        r3.c(r4, r5, r0);	 Catch:{ all -> 0x00b1 }
        r0 = c.e.a.b.e.c.n9.a();	 Catch:{ all -> 0x00b1 }
        if (r0 == 0) goto L_0x00ab;
    L_0x0095:
        r0 = r13.a;	 Catch:{ all -> 0x00b1 }
        r0 = r0.g;	 Catch:{ all -> 0x00b1 }
        r3 = c.e.a.b.f.b.p.F0;	 Catch:{ all -> 0x00b1 }
        r14 = r0.u(r14, r3);	 Catch:{ all -> 0x00b1 }
        if (r14 == 0) goto L_0x00ab;
    L_0x00a1:
        r14 = java.util.Collections.emptyList();	 Catch:{ all -> 0x00b1 }
        if (r2 == 0) goto L_0x00aa;
    L_0x00a7:
        r2.close();
    L_0x00aa:
        return r14;
    L_0x00ab:
        if (r2 == 0) goto L_0x00b0;
    L_0x00ad:
        r2.close();
    L_0x00b0:
        return r1;
    L_0x00b1:
        r14 = move-exception;
        r1 = r2;
    L_0x00b3:
        if (r1 == 0) goto L_0x00b8;
    L_0x00b5:
        r1.close();
    L_0x00b8:
        throw r14;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.C(java.lang.String):java.util.List");
    }

    public final List<Pair<e1, Long>> D(String str, int i, int i2) {
        g();
        n();
        f.J(i > 0);
        f.J(i2 > 0);
        f.N(str);
        Cursor cursor = null;
        try {
            cursor = t().query("queue", new String[]{"rowid", "data", "retry_count"}, "app_id=?", new String[]{str}, null, null, "rowid", String.valueOf(i));
            if (cursor.moveToFirst()) {
                ArrayList arrayList = new ArrayList();
                int i3 = 0;
                while (true) {
                    long j = cursor.getLong(0);
                    try {
                        byte[] S = m().S(cursor.getBlob(1));
                        if (!arrayList.isEmpty() && S.length + i3 > i2) {
                            break;
                        }
                        try {
                            a aVar = (a) q9.x(e1.u0(), S);
                            if (!cursor.isNull(2)) {
                                int i4 = cursor.getInt(2);
                                if (aVar.c) {
                                    aVar.j();
                                    aVar.c = false;
                                }
                                e1.V0((e1) aVar.b, i4);
                            }
                            i3 += S.length;
                            arrayList.add(Pair.create((e1) ((u4) aVar.l()), Long.valueOf(j)));
                        } catch (IOException e) {
                            d().f.c("Failed to merge queued bundle. appId", q3.s(str), e);
                        }
                        if (cursor.moveToNext()) {
                            if (i3 > i2) {
                                break;
                            }
                        }
                        break;
                    } catch (IOException e2) {
                        d().f.c("Failed to unzip queued bundle. appId", q3.s(str), e2);
                    }
                }
                cursor.close();
                return arrayList;
            }
            List emptyList = Collections.emptyList();
            cursor.close();
            return emptyList;
        } catch (SQLiteException e3) {
            d().f.c("Error querying bundles. appId", q3.s(str), e3);
            List<Pair<e1, Long>> emptyList2 = Collections.emptyList();
            return emptyList2;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:49:0x011b  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x0103 A:{Catch:{ all -> 0x011f }} */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x011b  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x0103 A:{Catch:{ all -> 0x011f }} */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x011b  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00e8 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:1:0x0013} */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x0123  */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:35:0x00e8, code skipped:
            r0 = th;
     */
    /* JADX WARNING: Missing block: B:36:0x00ea, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:37:0x00eb, code skipped:
            r4 = r23;
     */
    /* JADX WARNING: Missing block: B:44:0x010f, code skipped:
            r0 = java.util.Collections.emptyList();
     */
    /* JADX WARNING: Missing block: B:45:0x0113, code skipped:
            if (r12 != null) goto L_0x0115;
     */
    /* JADX WARNING: Missing block: B:46:0x0115, code skipped:
            r12.close();
     */
    /* JADX WARNING: Missing block: B:47:0x0118, code skipped:
            return r0;
     */
    /* JADX WARNING: Missing block: B:49:0x011b, code skipped:
            r12.close();
     */
    /* JADX WARNING: Missing block: B:54:0x0123, code skipped:
            r10.close();
     */
    public final java.util.List<c.e.a.b.f.b.u9> E(java.lang.String r22, java.lang.String r23, java.lang.String r24) {
        /*
        r21 = this;
        r1 = r21;
        r9 = r22;
        b.i.b.f.N(r22);
        r21.g();
        r21.n();
        r0 = new java.util.ArrayList;
        r0.<init>();
        r10 = 0;
        r2 = new java.util.ArrayList;	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        r11 = 3;
        r2.<init>(r11);	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        r2.add(r9);	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        r3 = new java.lang.StringBuilder;	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        r4 = "app_id=?";
        r3.<init>(r4);	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        r4 = android.text.TextUtils.isEmpty(r23);	 Catch:{ SQLiteException -> 0x00ea, all -> 0x00e8 }
        if (r4 != 0) goto L_0x0034;
    L_0x0029:
        r4 = r23;
        r2.add(r4);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r5 = " and origin=?";
        r3.append(r5);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        goto L_0x0036;
    L_0x0034:
        r4 = r23;
    L_0x0036:
        r5 = android.text.TextUtils.isEmpty(r24);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        if (r5 != 0) goto L_0x004e;
    L_0x003c:
        r5 = java.lang.String.valueOf(r24);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r6 = "*";
        r5 = r5.concat(r6);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r2.add(r5);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r5 = " and name glob ?";
        r3.append(r5);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
    L_0x004e:
        r5 = r2.size();	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r5 = new java.lang.String[r5];	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r2 = r2.toArray(r5);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r16 = r2;
        r16 = (java.lang.String[]) r16;	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r12 = r21.t();	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r13 = "user_attributes";
        r2 = "name";
        r5 = "set_timestamp";
        r6 = "value";
        r7 = "origin";
        r14 = new java.lang.String[]{r2, r5, r6, r7};	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r15 = r3.toString();	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r17 = 0;
        r18 = 0;
        r19 = "rowid";
        r20 = "1001";
        r12 = r12.query(r13, r14, r15, r16, r17, r18, r19, r20);	 Catch:{ SQLiteException -> 0x00e6, all -> 0x00e8 }
        r2 = r12.moveToFirst();	 Catch:{ SQLiteException -> 0x00e4 }
        if (r2 != 0) goto L_0x0088;
    L_0x0084:
        r12.close();
        return r0;
    L_0x0088:
        r2 = r0.size();	 Catch:{ SQLiteException -> 0x00e4 }
        r3 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        if (r2 < r3) goto L_0x00a0;
    L_0x0090:
        r2 = r21.d();	 Catch:{ SQLiteException -> 0x00e4 }
        r2 = r2.f;	 Catch:{ SQLiteException -> 0x00e4 }
        r5 = "Read more than the max allowed user properties, ignoring excess";
        r3 = java.lang.Integer.valueOf(r3);	 Catch:{ SQLiteException -> 0x00e4 }
        r2.b(r5, r3);	 Catch:{ SQLiteException -> 0x00e4 }
        goto L_0x00db;
    L_0x00a0:
        r2 = 0;
        r5 = r12.getString(r2);	 Catch:{ SQLiteException -> 0x00e4 }
        r2 = 1;
        r6 = r12.getLong(r2);	 Catch:{ SQLiteException -> 0x00e4 }
        r2 = 2;
        r8 = r1.A(r12, r2);	 Catch:{ SQLiteException -> 0x00e4 }
        r13 = r12.getString(r11);	 Catch:{ SQLiteException -> 0x00e4 }
        if (r8 != 0) goto L_0x00c7;
    L_0x00b5:
        r2 = r21.d();	 Catch:{ SQLiteException -> 0x00e1 }
        r2 = r2.f;	 Catch:{ SQLiteException -> 0x00e1 }
        r3 = "(2)Read invalid user property value, ignoring it";
        r4 = c.e.a.b.f.b.q3.s(r22);	 Catch:{ SQLiteException -> 0x00e1 }
        r14 = r24;
        r2.d(r3, r4, r13, r14);	 Catch:{ SQLiteException -> 0x00e1 }
        goto L_0x00d5;
    L_0x00c7:
        r14 = r24;
        r15 = new c.e.a.b.f.b.u9;	 Catch:{ SQLiteException -> 0x00e1 }
        r2 = r15;
        r3 = r22;
        r4 = r13;
        r2.m1502init(r3, r4, r5, r6, r8);	 Catch:{ SQLiteException -> 0x00e1 }
        r0.add(r15);	 Catch:{ SQLiteException -> 0x00e1 }
    L_0x00d5:
        r2 = r12.moveToNext();	 Catch:{ SQLiteException -> 0x00e1 }
        if (r2 != 0) goto L_0x00df;
    L_0x00db:
        r12.close();
        return r0;
    L_0x00df:
        r4 = r13;
        goto L_0x0088;
    L_0x00e1:
        r0 = move-exception;
        r4 = r13;
        goto L_0x00ee;
    L_0x00e4:
        r0 = move-exception;
        goto L_0x00ee;
    L_0x00e6:
        r0 = move-exception;
        goto L_0x00ed;
    L_0x00e8:
        r0 = move-exception;
        goto L_0x0121;
    L_0x00ea:
        r0 = move-exception;
        r4 = r23;
    L_0x00ed:
        r12 = r10;
    L_0x00ee:
        r2 = r21.d();	 Catch:{ all -> 0x011f }
        r2 = r2.f;	 Catch:{ all -> 0x011f }
        r3 = "(2)Error querying user properties";
        r5 = c.e.a.b.f.b.q3.s(r22);	 Catch:{ all -> 0x011f }
        r2.d(r3, r5, r4, r0);	 Catch:{ all -> 0x011f }
        r0 = c.e.a.b.e.c.n9.a();	 Catch:{ all -> 0x011f }
        if (r0 == 0) goto L_0x0119;
    L_0x0103:
        r0 = r1.a;	 Catch:{ all -> 0x011f }
        r0 = r0.g;	 Catch:{ all -> 0x011f }
        r2 = c.e.a.b.f.b.p.F0;	 Catch:{ all -> 0x011f }
        r0 = r0.u(r9, r2);	 Catch:{ all -> 0x011f }
        if (r0 == 0) goto L_0x0119;
    L_0x010f:
        r0 = java.util.Collections.emptyList();	 Catch:{ all -> 0x011f }
        if (r12 == 0) goto L_0x0118;
    L_0x0115:
        r12.close();
    L_0x0118:
        return r0;
    L_0x0119:
        if (r12 == 0) goto L_0x011e;
    L_0x011b:
        r12.close();
    L_0x011e:
        return r10;
    L_0x011f:
        r0 = move-exception;
        r10 = r12;
    L_0x0121:
        if (r10 == 0) goto L_0x0126;
    L_0x0123:
        r10.close();
    L_0x0126:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.E(java.lang.String, java.lang.String, java.lang.String):java.util.List");
    }

    public final List<zzz> F(String str, String[] strArr) {
        g();
        n();
        ArrayList arrayList = new ArrayList();
        Cursor cursor = null;
        try {
            cursor = t().query("conditional_properties", new String[]{HiAnalyticsConstant.BI_KEY_APP_ID, "origin", RankingConst.RANKING_JGW_NAME, "value", "active", "trigger_event_name", "trigger_timeout", "timed_out_event", "creation_timestamp", "triggered_event", "triggered_timestamp", "time_to_live", "expired_event"}, str, strArr, null, null, "rowid", "1001");
            if (cursor.moveToFirst()) {
                while (arrayList.size() < 1000) {
                    boolean z = false;
                    String string = cursor.getString(0);
                    String string2 = cursor.getString(1);
                    String string3 = cursor.getString(2);
                    Object A = A(cursor, 3);
                    if (cursor.getInt(4) != 0) {
                        z = true;
                    }
                    String string4 = cursor.getString(5);
                    long j = cursor.getLong(6);
                    q9 m = m();
                    byte[] blob = cursor.getBlob(7);
                    Creator creator = zzaq.CREATOR;
                    zzaq zzaq = (zzaq) m.u(blob, creator);
                    long j2 = cursor.getLong(8);
                    zzaq zzaq2 = (zzaq) m().u(cursor.getBlob(9), creator);
                    long j3 = cursor.getLong(10);
                    long j4 = cursor.getLong(11);
                    zzaq zzaq3 = (zzaq) m().u(cursor.getBlob(12), creator);
                    zzku zzku = new zzku(string3, j3, A, string2);
                    boolean z2 = z;
                    zzz zzz = r3;
                    zzz zzz2 = new zzz(string, string2, zzku, j2, z2, string4, zzaq, j, zzaq2, j4, zzaq3);
                    arrayList.add(zzz);
                    if (!cursor.moveToNext()) {
                        break;
                    }
                }
                d().f.b("Read more than the max allowed conditional properties, ignoring extra", Integer.valueOf(1000));
                cursor.close();
                return arrayList;
            }
            cursor.close();
            return arrayList;
        } catch (SQLiteException e) {
            d().f.b("Error querying conditional user property value", e);
            List<zzz> emptyList = Collections.emptyList();
            return emptyList;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    public final void H(l lVar) {
        Objects.requireNonNull(lVar, "null reference");
        g();
        n();
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, lVar.a);
        contentValues.put(RankingConst.RANKING_JGW_NAME, lVar.b);
        contentValues.put("lifetime_count", Long.valueOf(lVar.c));
        contentValues.put("current_bundle_count", Long.valueOf(lVar.d));
        contentValues.put("last_fire_timestamp", Long.valueOf(lVar.f));
        contentValues.put("last_bundled_timestamp", Long.valueOf(lVar.g));
        contentValues.put("last_bundled_day", lVar.h);
        contentValues.put("last_sampled_complex_event_id", lVar.i);
        contentValues.put("last_sampling_rate", lVar.j);
        contentValues.put("current_session_count", Long.valueOf(lVar.e));
        Boolean bool = lVar.k;
        Long valueOf = (bool == null || !bool.booleanValue()) ? null : Long.valueOf(1);
        contentValues.put("last_exempt_from_sampling", valueOf);
        try {
            if (t().insertWithOnConflict("events", null, contentValues, 5) == -1) {
                d().f.b("Failed to insert/update event aggregates (got -1). appId", q3.s(lVar.a));
            }
        } catch (SQLiteException e) {
            d().f.c("Error storing event aggregates. appId", q3.s(lVar.a), e);
        }
    }

    public final void I(a4 a4Var) {
        String str = "apps";
        g();
        n();
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, a4Var.o());
        contentValues.put("app_instance_id", a4Var.s());
        contentValues.put("gmp_app_id", a4Var.v());
        contentValues.put("resettable_device_id_hash", a4Var.E());
        contentValues.put("last_bundle_index", Long.valueOf(a4Var.U()));
        contentValues.put("last_bundle_start_timestamp", Long.valueOf(a4Var.K()));
        contentValues.put("last_bundle_end_timestamp", Long.valueOf(a4Var.L()));
        contentValues.put("app_version", a4Var.M());
        contentValues.put("app_store", a4Var.O());
        contentValues.put("gmp_version", Long.valueOf(a4Var.P()));
        contentValues.put("dev_cert_hash", Long.valueOf(a4Var.Q()));
        contentValues.put("measurement_enabled", Boolean.valueOf(a4Var.T()));
        a4Var.a.a().g();
        contentValues.put("day", Long.valueOf(a4Var.x));
        a4Var.a.a().g();
        contentValues.put("daily_public_events_count", Long.valueOf(a4Var.y));
        a4Var.a.a().g();
        contentValues.put("daily_events_count", Long.valueOf(a4Var.z));
        a4Var.a.a().g();
        contentValues.put("daily_conversions_count", Long.valueOf(a4Var.A));
        a4Var.a.a().g();
        contentValues.put("config_fetched_time", Long.valueOf(a4Var.F));
        a4Var.a.a().g();
        contentValues.put("failed_config_fetch_time", Long.valueOf(a4Var.G));
        contentValues.put("app_version_int", Long.valueOf(a4Var.N()));
        contentValues.put("firebase_instance_id", a4Var.H());
        a4Var.a.a().g();
        contentValues.put("daily_error_events_count", Long.valueOf(a4Var.B));
        a4Var.a.a().g();
        contentValues.put("daily_realtime_events_count", Long.valueOf(a4Var.C));
        a4Var.a.a().g();
        contentValues.put("health_monitor_sample", a4Var.D);
        contentValues.put("android_id", Long.valueOf(a4Var.g()));
        contentValues.put("adid_reporting_enabled", Boolean.valueOf(a4Var.h()));
        contentValues.put("ssaid_reporting_enabled", Boolean.valueOf(a4Var.i()));
        contentValues.put("admob_app_id", a4Var.y());
        contentValues.put("dynamite_version", Long.valueOf(a4Var.S()));
        if (a4Var.k() != null) {
            if (a4Var.k().size() == 0) {
                d().i.b("Safelisted events should not be an empty list. appId", a4Var.o());
            } else {
                contentValues.put("safelisted_events", TextUtils.join(",", a4Var.k()));
            }
        }
        if (fa.a() && this.a.g.u(a4Var.o(), p.j0)) {
            contentValues.put("ga_app_id", a4Var.B());
        }
        try {
            SQLiteDatabase t = t();
            if (((long) t.update(str, contentValues, "app_id = ?", new String[]{a4Var.o()})) == 0 && t.insertWithOnConflict(str, null, contentValues, 5) == -1) {
                d().f.b("Failed to insert/update app (got -1). appId", q3.s(a4Var.o()));
            }
        } catch (SQLiteException e) {
            d().f.c("Error storing app. appId", q3.s(a4Var.o()), e);
        }
    }

    public final void J(List<Long> list) {
        g();
        n();
        Objects.requireNonNull(list, "null reference");
        if (list.size() == 0) {
            throw new IllegalArgumentException("Given Integer is zero");
        } else if (R()) {
            String join = TextUtils.join(",", list);
            StringBuilder stringBuilder = new StringBuilder(String.valueOf(join).length() + 2);
            stringBuilder.append("(");
            stringBuilder.append(join);
            stringBuilder.append(")");
            join = stringBuilder.toString();
            stringBuilder = new StringBuilder(String.valueOf(join).length() + 80);
            stringBuilder.append("SELECT COUNT(1) FROM queue WHERE rowid IN ");
            stringBuilder.append(join);
            stringBuilder.append(" AND retry_count =  2147483647 LIMIT 1");
            if (S(stringBuilder.toString(), null) > 0) {
                d().i.a("The number of upload retries exceeds the limit. Will remain unchanged.");
            }
            try {
                SQLiteDatabase t = t();
                StringBuilder stringBuilder2 = new StringBuilder(String.valueOf(join).length() + 127);
                stringBuilder2.append("UPDATE queue SET retry_count = IFNULL(retry_count, 0) + 1 WHERE rowid IN ");
                stringBuilder2.append(join);
                stringBuilder2.append(" AND (retry_count IS NULL OR retry_count < 2147483647)");
                t.execSQL(stringBuilder2.toString());
            } catch (SQLiteException e) {
                d().f.b("Error incrementing retry count. error", e);
            }
        }
    }

    public final boolean K(e1 e1Var, boolean z) {
        g();
        n();
        f.N(e1Var.G1());
        if (e1Var.n1()) {
            i0();
            Objects.requireNonNull((c) this.a.n);
            long currentTimeMillis = System.currentTimeMillis();
            if (e1Var.o1() < currentTimeMillis - c.B() || e1Var.o1() > c.B() + currentTimeMillis) {
                d().i.d("Storing bundle outside of the max uploading time span. appId, now, timestamp", q3.s(e1Var.G1()), Long.valueOf(currentTimeMillis), Long.valueOf(e1Var.o1()));
            }
            try {
                byte[] T = m().T(e1Var.i());
                d().n.b("Saving bundle, size", Integer.valueOf(T.length));
                ContentValues contentValues = new ContentValues();
                contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, e1Var.G1());
                contentValues.put("bundle_end_timestamp", Long.valueOf(e1Var.o1()));
                contentValues.put("data", T);
                contentValues.put("has_realtime", Integer.valueOf(z));
                if (e1Var.f0()) {
                    contentValues.put("retry_count", Integer.valueOf(e1Var.n0()));
                }
                try {
                    if (t().insert("queue", null, contentValues) != -1) {
                        return true;
                    }
                    d().f.b("Failed to insert bundle (got -1). appId", q3.s(e1Var.G1()));
                    return false;
                } catch (SQLiteException e) {
                    d().f.c("Error storing bundle. appId", q3.s(e1Var.G1()), e);
                    return false;
                }
            } catch (IOException e2) {
                d().f.c("Data loss. Failed to serialize bundle. appId", q3.s(e1Var.G1()), e2);
                return false;
            }
        }
        throw new IllegalStateException();
    }

    public final boolean L(m mVar, long j, boolean z) {
        g();
        n();
        f.N(mVar.a);
        byte[] i = m().v(mVar).i();
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, mVar.a);
        contentValues.put(RankingConst.RANKING_JGW_NAME, mVar.b);
        contentValues.put("timestamp", Long.valueOf(mVar.d));
        contentValues.put("metadata_fingerprint", Long.valueOf(j));
        contentValues.put("data", i);
        contentValues.put("realtime", Integer.valueOf(z));
        try {
            if (t().insert("raw_events", null, contentValues) != -1) {
                return true;
            }
            d().f.b("Failed to insert raw event (got -1). appId", q3.s(mVar.a));
            return false;
        } catch (SQLiteException e) {
            d().f.c("Error storing raw event. appId", q3.s(mVar.a), e);
            return false;
        }
    }

    public final boolean M(u9 u9Var) {
        g();
        n();
        if (Y(u9Var.a, u9Var.c) == null) {
            if (t9.X(u9Var.c)) {
                long S = S("select count(1) from user_attributes where app_id=? and name not like '!_%' escape '!'", new String[]{u9Var.a});
                c cVar = this.a.g;
                String str = u9Var.a;
                Objects.requireNonNull(cVar);
                int i = 25;
                if (q8.a() && cVar.u(null, p.w0)) {
                    i = Math.max(Math.min(cVar.q(str, p.G), 100), 25);
                }
                if (S >= ((long) i)) {
                    return false;
                }
            }
            if (!"_npa".equals(u9Var.c)) {
                if (S("select count(1) from user_attributes where app_id=? and origin=? AND name like '!_%' escape '!'", new String[]{u9Var.a, u9Var.b}) >= 25) {
                    return false;
                }
            }
        }
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, u9Var.a);
        contentValues.put("origin", u9Var.b);
        contentValues.put(RankingConst.RANKING_JGW_NAME, u9Var.c);
        contentValues.put("set_timestamp", Long.valueOf(u9Var.d));
        G(contentValues, "value", u9Var.e);
        try {
            if (t().insertWithOnConflict("user_attributes", null, contentValues, 5) == -1) {
                d().f.b("Failed to insert/update user property (got -1). appId", q3.s(u9Var.a));
            }
        } catch (SQLiteException e) {
            d().f.c("Error storing user property. appId", q3.s(u9Var.a), e);
        }
        return true;
    }

    public final boolean N(zzz zzz) {
        g();
        n();
        if (Y(zzz.a, zzz.c.b) == null) {
            if (S("SELECT COUNT(1) FROM conditional_properties WHERE app_id=?", new String[]{zzz.a}) >= 1000) {
                return false;
            }
        }
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, zzz.a);
        contentValues.put("origin", zzz.b);
        contentValues.put(RankingConst.RANKING_JGW_NAME, zzz.c.b);
        G(contentValues, "value", zzz.c.b());
        contentValues.put("active", Boolean.valueOf(zzz.e));
        contentValues.put("trigger_event_name", zzz.f);
        contentValues.put("trigger_timeout", Long.valueOf(zzz.h));
        k();
        contentValues.put("timed_out_event", t9.g0(zzz.g));
        contentValues.put("creation_timestamp", Long.valueOf(zzz.d));
        k();
        contentValues.put("triggered_event", t9.g0(zzz.i));
        contentValues.put("triggered_timestamp", Long.valueOf(zzz.c.c));
        contentValues.put("time_to_live", Long.valueOf(zzz.j));
        k();
        contentValues.put("expired_event", t9.g0(zzz.k));
        try {
            if (t().insertWithOnConflict("conditional_properties", null, contentValues, 5) == -1) {
                d().f.b("Failed to insert/update conditional user property (got -1)", q3.s(zzz.a));
            }
        } catch (SQLiteException e) {
            d().f.c("Error storing conditional user property", q3.s(zzz.a), e);
        }
        return true;
    }

    public final boolean O(String str, int i, l0 l0Var) {
        n();
        g();
        f.N(str);
        Objects.requireNonNull(l0Var, "null reference");
        Object obj = null;
        if (TextUtils.isEmpty(l0Var.z())) {
            s3 s3Var = d().i;
            Object s = q3.s(str);
            Integer valueOf = Integer.valueOf(i);
            if (l0Var.x()) {
                obj = Integer.valueOf(l0Var.y());
            }
            s3Var.d("Event filter had no event name. Audience definition ignored. appId, audienceId, filterId", s, valueOf, String.valueOf(obj));
            return false;
        }
        byte[] i2 = l0Var.i();
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, str);
        contentValues.put("audience_id", Integer.valueOf(i));
        contentValues.put("filter_id", l0Var.x() ? Integer.valueOf(l0Var.y()) : null);
        contentValues.put("event_name", l0Var.z());
        contentValues.put("session_scoped", l0Var.G() ? Boolean.valueOf(l0Var.H()) : null);
        contentValues.put("data", i2);
        try {
            if (t().insertWithOnConflict("event_filters", null, contentValues, 5) == -1) {
                d().f.b("Failed to insert event filter (got -1). appId", q3.s(str));
            }
            return true;
        } catch (SQLiteException e) {
            d().f.c("Error storing event filter. appId", q3.s(str), e);
            return false;
        }
    }

    public final boolean P(String str, int i, o0 o0Var) {
        n();
        g();
        f.N(str);
        Objects.requireNonNull(o0Var, "null reference");
        Object obj = null;
        if (TextUtils.isEmpty(o0Var.x())) {
            s3 s3Var = d().i;
            Object s = q3.s(str);
            Integer valueOf = Integer.valueOf(i);
            if (o0Var.v()) {
                obj = Integer.valueOf(o0Var.w());
            }
            s3Var.d("Property filter had no property name. Audience definition ignored. appId, audienceId, filterId", s, valueOf, String.valueOf(obj));
            return false;
        }
        byte[] i2 = o0Var.i();
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, str);
        contentValues.put("audience_id", Integer.valueOf(i));
        contentValues.put("filter_id", o0Var.v() ? Integer.valueOf(o0Var.w()) : null);
        contentValues.put("property_name", o0Var.x());
        contentValues.put("session_scoped", o0Var.B() ? Boolean.valueOf(o0Var.C()) : null);
        contentValues.put("data", i2);
        try {
            if (t().insertWithOnConflict("property_filters", null, contentValues, 5) != -1) {
                return true;
            }
            d().f.b("Failed to insert property filter (got -1). appId", q3.s(str));
            return false;
        } catch (SQLiteException e) {
            d().f.c("Error storing property filter. appId", q3.s(str), e);
            return false;
        }
    }

    public final boolean Q(String str, Long l, long j, a1 a1Var) {
        g();
        n();
        String str2 = "null reference";
        Objects.requireNonNull(a1Var, str2);
        f.N(str);
        Objects.requireNonNull(l, str2);
        byte[] i = a1Var.i();
        d().n.c("Saving complex main event, appId, data size", j().u(str), Integer.valueOf(i.length));
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, str);
        contentValues.put("event_id", l);
        contentValues.put("children_to_process", Long.valueOf(j));
        contentValues.put("main_event", i);
        try {
            if (t().insertWithOnConflict("main_event_params", null, contentValues, 5) != -1) {
                return true;
            }
            d().f.b("Failed to insert complex main event (got -1). appId", q3.s(str));
            return false;
        } catch (SQLiteException e) {
            d().f.c("Error storing complex main event. appId", q3.s(str), e);
            return false;
        }
    }

    public final boolean R() {
        return this.a.a.getDatabasePath("google_app_measurement.db").exists();
    }

    public final long S(String str, String[] strArr) {
        Cursor cursor = null;
        try {
            cursor = t().rawQuery(str, strArr);
            if (cursor.moveToFirst()) {
                long j = cursor.getLong(0);
                cursor.close();
                return j;
            }
            throw new SQLiteException("Database returned empty set");
        } catch (SQLiteException e) {
            d().f.c("Database error", str, e);
            throw e;
        } catch (Throwable th) {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:60:0x0207 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x0224 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:66:0x0223 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x0233 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0271 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x00f2 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x00f0 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0111 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x010f A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x0130 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x012e A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x014f A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x014d A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0173 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x016f A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x019d A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x019b A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x01bc A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x01ba A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x01d9 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x01f2 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x0207 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:66:0x0223 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x0224 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x0233 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x0271 A:{Catch:{ SQLiteException -> 0x0284 }} */
    /* JADX WARNING: Removed duplicated region for block: B:88:0x029b  */
    /* JADX WARNING: Removed duplicated region for block: B:93:0x02a3  */
    public final c.e.a.b.f.b.a4 T(java.lang.String r36) {
        /*
        r35 = this;
        r1 = r35;
        r2 = r36;
        b.i.b.f.N(r36);
        r35.g();
        r35.n();
        r3 = 0;
        r4 = r35.t();	 Catch:{ SQLiteException -> 0x0288, all -> 0x0286 }
        r5 = "apps";
        r6 = "app_instance_id";
        r7 = "gmp_app_id";
        r8 = "resettable_device_id_hash";
        r9 = "last_bundle_index";
        r10 = "last_bundle_start_timestamp";
        r11 = "last_bundle_end_timestamp";
        r12 = "app_version";
        r13 = "app_store";
        r14 = "gmp_version";
        r15 = "dev_cert_hash";
        r16 = "measurement_enabled";
        r17 = "day";
        r18 = "daily_public_events_count";
        r19 = "daily_events_count";
        r20 = "daily_conversions_count";
        r21 = "config_fetched_time";
        r22 = "failed_config_fetch_time";
        r23 = "app_version_int";
        r24 = "firebase_instance_id";
        r25 = "daily_error_events_count";
        r26 = "daily_realtime_events_count";
        r27 = "health_monitor_sample";
        r28 = "android_id";
        r29 = "adid_reporting_enabled";
        r30 = "ssaid_reporting_enabled";
        r31 = "admob_app_id";
        r32 = "dynamite_version";
        r33 = "safelisted_events";
        r34 = "ga_app_id";
        r6 = new java.lang.String[]{r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31, r32, r33, r34};	 Catch:{ SQLiteException -> 0x0288, all -> 0x0286 }
        r7 = "app_id=?";
        r0 = 1;
        r8 = new java.lang.String[r0];	 Catch:{ SQLiteException -> 0x0288, all -> 0x0286 }
        r12 = 0;
        r8[r12] = r2;	 Catch:{ SQLiteException -> 0x0288, all -> 0x0286 }
        r9 = 0;
        r10 = 0;
        r11 = 0;
        r4 = r4.query(r5, r6, r7, r8, r9, r10, r11);	 Catch:{ SQLiteException -> 0x0288, all -> 0x0286 }
        r5 = r4.moveToFirst();	 Catch:{ SQLiteException -> 0x0284 }
        if (r5 != 0) goto L_0x006b;
    L_0x0067:
        r4.close();
        return r3;
    L_0x006b:
        r5 = new c.e.a.b.f.b.a4;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r1.b;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r6.j;	 Catch:{ SQLiteException -> 0x0284 }
        r5.m1377init(r6, r2);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r4.getString(r12);	 Catch:{ SQLiteException -> 0x0284 }
        r5.c(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r4.getString(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r5.m(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 2;
        r6 = r4.getString(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.x(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 3;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.C(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 4;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.a(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 5;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.l(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 6;
        r6 = r4.getString(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.D(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 7;
        r6 = r4.getString(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.G(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 8;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.t(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 9;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.w(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 10;
        r7 = r4.isNull(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r7 != 0) goto L_0x00d5;
    L_0x00cc:
        r6 = r4.getInt(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r6 == 0) goto L_0x00d3;
    L_0x00d2:
        goto L_0x00d5;
    L_0x00d3:
        r6 = 0;
        goto L_0x00d6;
    L_0x00d5:
        r6 = 1;
    L_0x00d6:
        r5.e(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 11;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.x;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x00f2;
    L_0x00f0:
        r9 = 1;
        goto L_0x00f3;
    L_0x00f2:
        r9 = 0;
    L_0x00f3:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.x = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 12;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.y;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x0111;
    L_0x010f:
        r9 = 1;
        goto L_0x0112;
    L_0x0111:
        r9 = 0;
    L_0x0112:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.y = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 13;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.z;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x0130;
    L_0x012e:
        r9 = 1;
        goto L_0x0131;
    L_0x0130:
        r9 = 0;
    L_0x0131:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.z = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 14;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.A;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x014f;
    L_0x014d:
        r9 = 1;
        goto L_0x0150;
    L_0x014f:
        r9 = 0;
    L_0x0150:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.A = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 15;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.F(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 16;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.I(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 17;
        r7 = r4.isNull(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r7 == 0) goto L_0x0173;
    L_0x016f:
        r6 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        goto L_0x0178;
    L_0x0173:
        r6 = r4.getInt(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = (long) r6;	 Catch:{ SQLiteException -> 0x0284 }
    L_0x0178:
        r5.p(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 18;
        r6 = r4.getString(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.A(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 19;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.B;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x019d;
    L_0x019b:
        r9 = 1;
        goto L_0x019e;
    L_0x019d:
        r9 = 0;
    L_0x019e:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.B = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 20;
        r6 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r8.a();	 Catch:{ SQLiteException -> 0x0284 }
        r8.g();	 Catch:{ SQLiteException -> 0x0284 }
        r8 = r5.E;	 Catch:{ SQLiteException -> 0x0284 }
        r9 = r5.C;	 Catch:{ SQLiteException -> 0x0284 }
        r11 = (r9 > r6 ? 1 : (r9 == r6 ? 0 : -1));
        if (r11 == 0) goto L_0x01bc;
    L_0x01ba:
        r9 = 1;
        goto L_0x01bd;
    L_0x01bc:
        r9 = 0;
    L_0x01bd:
        r8 = r8 | r9;
        r5.E = r8;	 Catch:{ SQLiteException -> 0x0284 }
        r5.C = r6;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 21;
        r6 = r4.getString(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r5.J(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r1.a;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r6.g;	 Catch:{ SQLiteException -> 0x0284 }
        r7 = c.e.a.b.f.b.p.y0;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = r6.o(r7);	 Catch:{ SQLiteException -> 0x0284 }
        r7 = 0;
        if (r6 != 0) goto L_0x01ea;
    L_0x01d9:
        r6 = 22;
        r9 = r4.isNull(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r9 == 0) goto L_0x01e3;
    L_0x01e1:
        r9 = r7;
        goto L_0x01e7;
    L_0x01e3:
        r9 = r4.getLong(r6);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x01e7:
        r5.R(r9);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x01ea:
        r6 = 23;
        r9 = r4.isNull(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r9 != 0) goto L_0x01fb;
    L_0x01f2:
        r6 = r4.getInt(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r6 == 0) goto L_0x01f9;
    L_0x01f8:
        goto L_0x01fb;
    L_0x01f9:
        r6 = 0;
        goto L_0x01fc;
    L_0x01fb:
        r6 = 1;
    L_0x01fc:
        r5.n(r6);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = 24;
        r9 = r4.isNull(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r9 != 0) goto L_0x020f;
    L_0x0207:
        r6 = r4.getInt(r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r6 == 0) goto L_0x020e;
    L_0x020d:
        goto L_0x020f;
    L_0x020e:
        r0 = 0;
    L_0x020f:
        r5.r(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r0 = 25;
        r0 = r4.getString(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r5.q(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r0 = 26;
        r6 = r4.isNull(r0);	 Catch:{ SQLiteException -> 0x0284 }
        if (r6 == 0) goto L_0x0224;
    L_0x0223:
        goto L_0x0228;
    L_0x0224:
        r7 = r4.getLong(r0);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x0228:
        r5.z(r7);	 Catch:{ SQLiteException -> 0x0284 }
        r0 = 27;
        r6 = r4.isNull(r0);	 Catch:{ SQLiteException -> 0x0284 }
        if (r6 != 0) goto L_0x0245;
    L_0x0233:
        r0 = r4.getString(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r6 = ",";
        r7 = -1;
        r0 = r0.split(r6, r7);	 Catch:{ SQLiteException -> 0x0284 }
        r0 = java.util.Arrays.asList(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r5.d(r0);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x0245:
        r0 = c.e.a.b.e.c.fa.a();	 Catch:{ SQLiteException -> 0x0284 }
        if (r0 == 0) goto L_0x0260;
    L_0x024b:
        r0 = r1.a;	 Catch:{ SQLiteException -> 0x0284 }
        r0 = r0.g;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = c.e.a.b.f.b.p.j0;	 Catch:{ SQLiteException -> 0x0284 }
        r0 = r0.u(r2, r6);	 Catch:{ SQLiteException -> 0x0284 }
        if (r0 == 0) goto L_0x0260;
    L_0x0257:
        r0 = 28;
        r0 = r4.getString(r0);	 Catch:{ SQLiteException -> 0x0284 }
        r5.u(r0);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x0260:
        r0 = r5.a;	 Catch:{ SQLiteException -> 0x0284 }
        r0 = r0.a();	 Catch:{ SQLiteException -> 0x0284 }
        r0.g();	 Catch:{ SQLiteException -> 0x0284 }
        r5.E = r12;	 Catch:{ SQLiteException -> 0x0284 }
        r0 = r4.moveToNext();	 Catch:{ SQLiteException -> 0x0284 }
        if (r0 == 0) goto L_0x0280;
    L_0x0271:
        r0 = r35.d();	 Catch:{ SQLiteException -> 0x0284 }
        r0 = r0.f;	 Catch:{ SQLiteException -> 0x0284 }
        r6 = "Got multiple records for app, expected one. appId";
        r7 = c.e.a.b.f.b.q3.s(r36);	 Catch:{ SQLiteException -> 0x0284 }
        r0.b(r6, r7);	 Catch:{ SQLiteException -> 0x0284 }
    L_0x0280:
        r4.close();
        return r5;
    L_0x0284:
        r0 = move-exception;
        goto L_0x028a;
    L_0x0286:
        r0 = move-exception;
        goto L_0x02a1;
    L_0x0288:
        r0 = move-exception;
        r4 = r3;
    L_0x028a:
        r5 = r35.d();	 Catch:{ all -> 0x029f }
        r5 = r5.f;	 Catch:{ all -> 0x029f }
        r6 = "Error querying app. appId";
        r2 = c.e.a.b.f.b.q3.s(r36);	 Catch:{ all -> 0x029f }
        r5.c(r6, r2, r0);	 Catch:{ all -> 0x029f }
        if (r4 == 0) goto L_0x029e;
    L_0x029b:
        r4.close();
    L_0x029e:
        return r3;
    L_0x029f:
        r0 = move-exception;
        r3 = r4;
    L_0x02a1:
        if (r3 == 0) goto L_0x02a6;
    L_0x02a3:
        r3.close();
    L_0x02a6:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.T(java.lang.String):c.e.a.b.f.b.a4");
    }

    public final List<zzz> U(String str, String str2, String str3) {
        f.N(str);
        g();
        n();
        ArrayList arrayList = new ArrayList(3);
        arrayList.add(str);
        StringBuilder stringBuilder = new StringBuilder("app_id=?");
        if (!TextUtils.isEmpty(str2)) {
            arrayList.add(str2);
            stringBuilder.append(" and origin=?");
        }
        if (!TextUtils.isEmpty(str3)) {
            arrayList.add(String.valueOf(str3).concat("*"));
            stringBuilder.append(" and name glob ?");
        }
        return F(stringBuilder.toString(), (String[]) arrayList.toArray(new String[arrayList.size()]));
    }

    public final void V(String str, String str2) {
        f.N(str);
        f.N(str2);
        g();
        n();
        try {
            t().delete("user_attributes", "app_id=? and name=?", new String[]{str, str2});
        } catch (SQLiteException e) {
            d().f.d("Error deleting user property. appId", q3.s(str), j().y(str2), e);
        }
    }

    public final boolean W(String str, List<Integer> list) {
        f.N(str);
        n();
        g();
        SQLiteDatabase t = t();
        try {
            if (S("select count(1) from audience_filter_values where app_id=?", new String[]{str}) <= ((long) Math.max(0, Math.min(2000, this.a.g.q(str, p.F))))) {
                return false;
            }
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < list.size(); i++) {
                Integer num = (Integer) list.get(i);
                if (num == null) {
                    return false;
                }
                arrayList.add(Integer.toString(num.intValue()));
            }
            String join = TextUtils.join(",", arrayList);
            StringBuilder stringBuilder = new StringBuilder(String.valueOf(join).length() + 2);
            stringBuilder.append("(");
            stringBuilder.append(join);
            stringBuilder.append(")");
            join = stringBuilder.toString();
            stringBuilder = new StringBuilder(String.valueOf(join).length() + 140);
            stringBuilder.append("audience_id in (select audience_id from audience_filter_values where app_id=? and audience_id not in ");
            stringBuilder.append(join);
            stringBuilder.append(" order by rowid desc limit -1 offset ?)");
            return t.delete("audience_filter_values", stringBuilder.toString(), new String[]{str, Integer.toString(r2)}) > 0;
        } catch (SQLiteException e) {
            d().f.c("Database error querying filters. appId", q3.s(str), e);
            return false;
        }
    }

    public final long X(String str) {
        f.N(str);
        g();
        n();
        try {
            SQLiteDatabase t = t();
            String valueOf = String.valueOf(Math.max(0, Math.min(1000000, this.a.g.q(str, p.p))));
            str = t.delete("raw_events", "rowid in (select rowid from raw_events where app_id=? order by rowid desc limit -1 offset ?)", new String[]{str, valueOf});
            return (long) str;
        } catch (SQLiteException e) {
            d().f.c("Error deleting over the limit events. appId", q3.s(str), e);
            return 0;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:29:0x0099  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x00a1  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0099  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x00a1  */
    public final c.e.a.b.f.b.u9 Y(java.lang.String r19, java.lang.String r20) {
        /*
        r18 = this;
        r8 = r20;
        b.i.b.f.N(r19);
        b.i.b.f.N(r20);
        r18.g();
        r18.n();
        r9 = 0;
        r10 = r18.t();	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r11 = "user_attributes";
        r0 = "set_timestamp";
        r1 = "value";
        r2 = "origin";
        r12 = new java.lang.String[]{r0, r1, r2};	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r13 = "app_id=? and name=?";
        r0 = 2;
        r14 = new java.lang.String[r0];	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r1 = 0;
        r14[r1] = r19;	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r2 = 1;
        r14[r2] = r8;	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r15 = 0;
        r16 = 0;
        r17 = 0;
        r10 = r10.query(r11, r12, r13, r14, r15, r16, r17);	 Catch:{ SQLiteException -> 0x007c, all -> 0x0078 }
        r3 = r10.moveToFirst();	 Catch:{ SQLiteException -> 0x0074, all -> 0x0070 }
        if (r3 != 0) goto L_0x003d;
    L_0x0039:
        r10.close();
        return r9;
    L_0x003d:
        r5 = r10.getLong(r1);	 Catch:{ SQLiteException -> 0x0074, all -> 0x0070 }
        r11 = r18;
        r7 = r11.A(r10, r2);	 Catch:{ SQLiteException -> 0x006e }
        r3 = r10.getString(r0);	 Catch:{ SQLiteException -> 0x006e }
        r0 = new c.e.a.b.f.b.u9;	 Catch:{ SQLiteException -> 0x006e }
        r1 = r0;
        r2 = r19;
        r4 = r20;
        r1.m1502init(r2, r3, r4, r5, r7);	 Catch:{ SQLiteException -> 0x006e }
        r1 = r10.moveToNext();	 Catch:{ SQLiteException -> 0x006e }
        if (r1 == 0) goto L_0x006a;
    L_0x005b:
        r1 = r18.d();	 Catch:{ SQLiteException -> 0x006e }
        r1 = r1.f;	 Catch:{ SQLiteException -> 0x006e }
        r2 = "Got multiple records for user property, expected one. appId";
        r3 = c.e.a.b.f.b.q3.s(r19);	 Catch:{ SQLiteException -> 0x006e }
        r1.b(r2, r3);	 Catch:{ SQLiteException -> 0x006e }
    L_0x006a:
        r10.close();
        return r0;
    L_0x006e:
        r0 = move-exception;
        goto L_0x0080;
    L_0x0070:
        r0 = move-exception;
        r11 = r18;
        goto L_0x009e;
    L_0x0074:
        r0 = move-exception;
        r11 = r18;
        goto L_0x0080;
    L_0x0078:
        r0 = move-exception;
        r11 = r18;
        goto L_0x009f;
    L_0x007c:
        r0 = move-exception;
        r11 = r18;
        r10 = r9;
    L_0x0080:
        r1 = r18.d();	 Catch:{ all -> 0x009d }
        r1 = r1.f;	 Catch:{ all -> 0x009d }
        r2 = "Error querying user property. appId";
        r3 = c.e.a.b.f.b.q3.s(r19);	 Catch:{ all -> 0x009d }
        r4 = r18.j();	 Catch:{ all -> 0x009d }
        r4 = r4.y(r8);	 Catch:{ all -> 0x009d }
        r1.d(r2, r3, r4, r0);	 Catch:{ all -> 0x009d }
        if (r10 == 0) goto L_0x009c;
    L_0x0099:
        r10.close();
    L_0x009c:
        return r9;
    L_0x009d:
        r0 = move-exception;
    L_0x009e:
        r9 = r10;
    L_0x009f:
        if (r9 == 0) goto L_0x00a4;
    L_0x00a1:
        r9.close();
    L_0x00a4:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.Y(java.lang.String, java.lang.String):c.e.a.b.f.b.u9");
    }

    /* JADX WARNING: Removed duplicated region for block: B:33:0x0111  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x0119  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x0111  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x0119  */
    public final com.google.android.gms.measurement.internal.zzz Z(java.lang.String r30, java.lang.String r31) {
        /*
        r29 = this;
        r7 = r31;
        b.i.b.f.N(r30);
        b.i.b.f.N(r31);
        r29.g();
        r29.n();
        r8 = 0;
        r9 = r29.t();	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r10 = "conditional_properties";
        r11 = "origin";
        r12 = "value";
        r13 = "active";
        r14 = "trigger_event_name";
        r15 = "trigger_timeout";
        r16 = "timed_out_event";
        r17 = "creation_timestamp";
        r18 = "triggered_event";
        r19 = "triggered_timestamp";
        r20 = "time_to_live";
        r21 = "expired_event";
        r11 = new java.lang.String[]{r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21};	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r12 = "app_id=? and name=?";
        r0 = 2;
        r13 = new java.lang.String[r0];	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r1 = 0;
        r13[r1] = r30;	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r2 = 1;
        r13[r2] = r7;	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r14 = 0;
        r15 = 0;
        r16 = 0;
        r9 = r9.query(r10, r11, r12, r13, r14, r15, r16);	 Catch:{ SQLiteException -> 0x00f4, all -> 0x00f0 }
        r3 = r9.moveToFirst();	 Catch:{ SQLiteException -> 0x00ec, all -> 0x00e8 }
        if (r3 != 0) goto L_0x004c;
    L_0x0048:
        r9.close();
        return r8;
    L_0x004c:
        r16 = r9.getString(r1);	 Catch:{ SQLiteException -> 0x00ec, all -> 0x00e8 }
        r10 = r29;
        r5 = r10.A(r9, r2);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r9.getInt(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        if (r0 == 0) goto L_0x005f;
    L_0x005c:
        r20 = 1;
        goto L_0x0061;
    L_0x005f:
        r20 = 0;
    L_0x0061:
        r0 = 3;
        r21 = r9.getString(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = 4;
        r23 = r9.getLong(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r29.m();	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = 5;
        r1 = r9.getBlob(r1);	 Catch:{ SQLiteException -> 0x00e6 }
        r2 = com.google.android.gms.measurement.internal.zzaq.CREATOR;	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r0.u(r1, r2);	 Catch:{ SQLiteException -> 0x00e6 }
        r22 = r0;
        r22 = (com.google.android.gms.measurement.internal.zzaq) r22;	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = 6;
        r18 = r9.getLong(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r29.m();	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = 7;
        r1 = r9.getBlob(r1);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r0.u(r1, r2);	 Catch:{ SQLiteException -> 0x00e6 }
        r25 = r0;
        r25 = (com.google.android.gms.measurement.internal.zzaq) r25;	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = 8;
        r3 = r9.getLong(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = 9;
        r26 = r9.getLong(r0);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r29.m();	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = 10;
        r1 = r9.getBlob(r1);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = r0.u(r1, r2);	 Catch:{ SQLiteException -> 0x00e6 }
        r28 = r0;
        r28 = (com.google.android.gms.measurement.internal.zzaq) r28;	 Catch:{ SQLiteException -> 0x00e6 }
        r17 = new com.google.android.gms.measurement.internal.zzku;	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = r17;
        r2 = r31;
        r6 = r16;
        r1.m8204init(r2, r3, r5, r6);	 Catch:{ SQLiteException -> 0x00e6 }
        r0 = new com.google.android.gms.measurement.internal.zzz;	 Catch:{ SQLiteException -> 0x00e6 }
        r14 = r0;
        r15 = r30;
        r14.m8210init(r15, r16, r17, r18, r20, r21, r22, r23, r25, r26, r28);	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = r9.moveToNext();	 Catch:{ SQLiteException -> 0x00e6 }
        if (r1 == 0) goto L_0x00e2;
    L_0x00cb:
        r1 = r29.d();	 Catch:{ SQLiteException -> 0x00e6 }
        r1 = r1.f;	 Catch:{ SQLiteException -> 0x00e6 }
        r2 = "Got multiple records for conditional property, expected one";
        r3 = c.e.a.b.f.b.q3.s(r30);	 Catch:{ SQLiteException -> 0x00e6 }
        r4 = r29.j();	 Catch:{ SQLiteException -> 0x00e6 }
        r4 = r4.y(r7);	 Catch:{ SQLiteException -> 0x00e6 }
        r1.c(r2, r3, r4);	 Catch:{ SQLiteException -> 0x00e6 }
    L_0x00e2:
        r9.close();
        return r0;
    L_0x00e6:
        r0 = move-exception;
        goto L_0x00f8;
    L_0x00e8:
        r0 = move-exception;
        r10 = r29;
        goto L_0x0116;
    L_0x00ec:
        r0 = move-exception;
        r10 = r29;
        goto L_0x00f8;
    L_0x00f0:
        r0 = move-exception;
        r10 = r29;
        goto L_0x0117;
    L_0x00f4:
        r0 = move-exception;
        r10 = r29;
        r9 = r8;
    L_0x00f8:
        r1 = r29.d();	 Catch:{ all -> 0x0115 }
        r1 = r1.f;	 Catch:{ all -> 0x0115 }
        r2 = "Error querying conditional property";
        r3 = c.e.a.b.f.b.q3.s(r30);	 Catch:{ all -> 0x0115 }
        r4 = r29.j();	 Catch:{ all -> 0x0115 }
        r4 = r4.y(r7);	 Catch:{ all -> 0x0115 }
        r1.d(r2, r3, r4, r0);	 Catch:{ all -> 0x0115 }
        if (r9 == 0) goto L_0x0114;
    L_0x0111:
        r9.close();
    L_0x0114:
        return r8;
    L_0x0115:
        r0 = move-exception;
    L_0x0116:
        r8 = r9;
    L_0x0117:
        if (r8 == 0) goto L_0x011c;
    L_0x0119:
        r8.close();
    L_0x011c:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.Z(java.lang.String, java.lang.String):com.google.android.gms.measurement.internal.zzz");
    }

    public final int a0(String str, String str2) {
        f.N(str);
        f.N(str2);
        g();
        n();
        try {
            str = t().delete("conditional_properties", "app_id=? and name=?", new String[]{str, str2});
            return str;
        } catch (SQLiteException e) {
            d().f.d("Error deleting conditional property", q3.s(str), j().y(str2), e);
            return 0;
        }
    }

    public final void b0() {
        n();
        t().beginTransaction();
    }

    /* JADX WARNING: Removed duplicated region for block: B:43:0x00cb  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c3  */
    public final java.util.Map<java.lang.Integer, java.util.List<c.e.a.b.e.c.l0>> c0(java.lang.String r13, java.lang.String r14) {
        /*
        r12 = this;
        r12.n();
        r12.g();
        b.i.b.f.N(r13);
        b.i.b.f.N(r14);
        r0 = new b.f.a;
        r0.m5038init();
        r1 = r12.t();
        r9 = 0;
        r2 = "event_filters";
        r3 = "audience_id";
        r4 = "data";
        r3 = new java.lang.String[]{r3, r4};	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r4 = "app_id=? AND event_name=?";
        r5 = 2;
        r5 = new java.lang.String[r5];	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r10 = 0;
        r5[r10] = r13;	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r11 = 1;
        r5[r11] = r14;	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r6 = 0;
        r7 = 0;
        r8 = 0;
        r14 = r1.query(r2, r3, r4, r5, r6, r7, r8);	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r1 = r14.moveToFirst();	 Catch:{ SQLiteException -> 0x0090 }
        if (r1 != 0) goto L_0x0040;
    L_0x0038:
        r13 = java.util.Collections.emptyMap();	 Catch:{ SQLiteException -> 0x0090 }
        r14.close();
        return r13;
    L_0x0040:
        r1 = r14.getBlob(r11);	 Catch:{ SQLiteException -> 0x0090 }
        r2 = c.e.a.b.e.c.l0.I();	 Catch:{ IOException -> 0x0076 }
        r1 = c.e.a.b.f.b.q9.x(r2, r1);	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.l0.a) r1;	 Catch:{ IOException -> 0x0076 }
        r1 = r1.l();	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.u4) r1;	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.l0) r1;	 Catch:{ IOException -> 0x0076 }
        r2 = r14.getInt(r10);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = java.lang.Integer.valueOf(r2);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = r0.get(r3);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = (java.util.List) r3;	 Catch:{ SQLiteException -> 0x0090 }
        if (r3 != 0) goto L_0x0072;
    L_0x0066:
        r3 = new java.util.ArrayList;	 Catch:{ SQLiteException -> 0x0090 }
        r3.<init>();	 Catch:{ SQLiteException -> 0x0090 }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ SQLiteException -> 0x0090 }
        r0.put(r2, r3);	 Catch:{ SQLiteException -> 0x0090 }
    L_0x0072:
        r3.add(r1);	 Catch:{ SQLiteException -> 0x0090 }
        goto L_0x0086;
    L_0x0076:
        r1 = move-exception;
        r2 = r12.d();	 Catch:{ SQLiteException -> 0x0090 }
        r2 = r2.f;	 Catch:{ SQLiteException -> 0x0090 }
        r3 = "Failed to merge filter. appId";
        r4 = c.e.a.b.f.b.q3.s(r13);	 Catch:{ SQLiteException -> 0x0090 }
        r2.c(r3, r4, r1);	 Catch:{ SQLiteException -> 0x0090 }
    L_0x0086:
        r1 = r14.moveToNext();	 Catch:{ SQLiteException -> 0x0090 }
        if (r1 != 0) goto L_0x0040;
    L_0x008c:
        r14.close();
        return r0;
    L_0x0090:
        r0 = move-exception;
        goto L_0x0096;
    L_0x0092:
        r13 = move-exception;
        goto L_0x00c9;
    L_0x0094:
        r0 = move-exception;
        r14 = r9;
    L_0x0096:
        r1 = r12.d();	 Catch:{ all -> 0x00c7 }
        r1 = r1.f;	 Catch:{ all -> 0x00c7 }
        r2 = "Database error querying filters. appId";
        r3 = c.e.a.b.f.b.q3.s(r13);	 Catch:{ all -> 0x00c7 }
        r1.c(r2, r3, r0);	 Catch:{ all -> 0x00c7 }
        r0 = c.e.a.b.e.c.n9.a();	 Catch:{ all -> 0x00c7 }
        if (r0 == 0) goto L_0x00c1;
    L_0x00ab:
        r0 = r12.a;	 Catch:{ all -> 0x00c7 }
        r0 = r0.g;	 Catch:{ all -> 0x00c7 }
        r1 = c.e.a.b.f.b.p.F0;	 Catch:{ all -> 0x00c7 }
        r13 = r0.u(r13, r1);	 Catch:{ all -> 0x00c7 }
        if (r13 == 0) goto L_0x00c1;
    L_0x00b7:
        r13 = java.util.Collections.emptyMap();	 Catch:{ all -> 0x00c7 }
        if (r14 == 0) goto L_0x00c0;
    L_0x00bd:
        r14.close();
    L_0x00c0:
        return r13;
    L_0x00c1:
        if (r14 == 0) goto L_0x00c6;
    L_0x00c3:
        r14.close();
    L_0x00c6:
        return r9;
    L_0x00c7:
        r13 = move-exception;
        r9 = r14;
    L_0x00c9:
        if (r9 == 0) goto L_0x00ce;
    L_0x00cb:
        r9.close();
    L_0x00ce:
        throw r13;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.c0(java.lang.String, java.lang.String):java.util.Map");
    }

    /* JADX WARNING: Removed duplicated region for block: B:43:0x00cb  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c3  */
    public final java.util.Map<java.lang.Integer, java.util.List<c.e.a.b.e.c.o0>> d0(java.lang.String r13, java.lang.String r14) {
        /*
        r12 = this;
        r12.n();
        r12.g();
        b.i.b.f.N(r13);
        b.i.b.f.N(r14);
        r0 = new b.f.a;
        r0.m5038init();
        r1 = r12.t();
        r9 = 0;
        r2 = "property_filters";
        r3 = "audience_id";
        r4 = "data";
        r3 = new java.lang.String[]{r3, r4};	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r4 = "app_id=? AND property_name=?";
        r5 = 2;
        r5 = new java.lang.String[r5];	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r10 = 0;
        r5[r10] = r13;	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r11 = 1;
        r5[r11] = r14;	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r6 = 0;
        r7 = 0;
        r8 = 0;
        r14 = r1.query(r2, r3, r4, r5, r6, r7, r8);	 Catch:{ SQLiteException -> 0x0094, all -> 0x0092 }
        r1 = r14.moveToFirst();	 Catch:{ SQLiteException -> 0x0090 }
        if (r1 != 0) goto L_0x0040;
    L_0x0038:
        r13 = java.util.Collections.emptyMap();	 Catch:{ SQLiteException -> 0x0090 }
        r14.close();
        return r13;
    L_0x0040:
        r1 = r14.getBlob(r11);	 Catch:{ SQLiteException -> 0x0090 }
        r2 = c.e.a.b.e.c.o0.D();	 Catch:{ IOException -> 0x0076 }
        r1 = c.e.a.b.f.b.q9.x(r2, r1);	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.o0.a) r1;	 Catch:{ IOException -> 0x0076 }
        r1 = r1.l();	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.u4) r1;	 Catch:{ IOException -> 0x0076 }
        r1 = (c.e.a.b.e.c.o0) r1;	 Catch:{ IOException -> 0x0076 }
        r2 = r14.getInt(r10);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = java.lang.Integer.valueOf(r2);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = r0.get(r3);	 Catch:{ SQLiteException -> 0x0090 }
        r3 = (java.util.List) r3;	 Catch:{ SQLiteException -> 0x0090 }
        if (r3 != 0) goto L_0x0072;
    L_0x0066:
        r3 = new java.util.ArrayList;	 Catch:{ SQLiteException -> 0x0090 }
        r3.<init>();	 Catch:{ SQLiteException -> 0x0090 }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ SQLiteException -> 0x0090 }
        r0.put(r2, r3);	 Catch:{ SQLiteException -> 0x0090 }
    L_0x0072:
        r3.add(r1);	 Catch:{ SQLiteException -> 0x0090 }
        goto L_0x0086;
    L_0x0076:
        r1 = move-exception;
        r2 = r12.d();	 Catch:{ SQLiteException -> 0x0090 }
        r2 = r2.f;	 Catch:{ SQLiteException -> 0x0090 }
        r3 = "Failed to merge filter";
        r4 = c.e.a.b.f.b.q3.s(r13);	 Catch:{ SQLiteException -> 0x0090 }
        r2.c(r3, r4, r1);	 Catch:{ SQLiteException -> 0x0090 }
    L_0x0086:
        r1 = r14.moveToNext();	 Catch:{ SQLiteException -> 0x0090 }
        if (r1 != 0) goto L_0x0040;
    L_0x008c:
        r14.close();
        return r0;
    L_0x0090:
        r0 = move-exception;
        goto L_0x0096;
    L_0x0092:
        r13 = move-exception;
        goto L_0x00c9;
    L_0x0094:
        r0 = move-exception;
        r14 = r9;
    L_0x0096:
        r1 = r12.d();	 Catch:{ all -> 0x00c7 }
        r1 = r1.f;	 Catch:{ all -> 0x00c7 }
        r2 = "Database error querying filters. appId";
        r3 = c.e.a.b.f.b.q3.s(r13);	 Catch:{ all -> 0x00c7 }
        r1.c(r2, r3, r0);	 Catch:{ all -> 0x00c7 }
        r0 = c.e.a.b.e.c.n9.a();	 Catch:{ all -> 0x00c7 }
        if (r0 == 0) goto L_0x00c1;
    L_0x00ab:
        r0 = r12.a;	 Catch:{ all -> 0x00c7 }
        r0 = r0.g;	 Catch:{ all -> 0x00c7 }
        r1 = c.e.a.b.f.b.p.F0;	 Catch:{ all -> 0x00c7 }
        r13 = r0.u(r13, r1);	 Catch:{ all -> 0x00c7 }
        if (r13 == 0) goto L_0x00c1;
    L_0x00b7:
        r13 = java.util.Collections.emptyMap();	 Catch:{ all -> 0x00c7 }
        if (r14 == 0) goto L_0x00c0;
    L_0x00bd:
        r14.close();
    L_0x00c0:
        return r13;
    L_0x00c1:
        if (r14 == 0) goto L_0x00c6;
    L_0x00c3:
        r14.close();
    L_0x00c6:
        return r9;
    L_0x00c7:
        r13 = move-exception;
        r9 = r14;
    L_0x00c9:
        if (r9 == 0) goto L_0x00ce;
    L_0x00cb:
        r9.close();
    L_0x00ce:
        throw r13;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.d0(java.lang.String, java.lang.String):java.util.Map");
    }

    public final void e0() {
        n();
        t().endTransaction();
    }

    public final long f0(String str) {
        f.N(str);
        return w("select count(1) from events where app_id=? and name not like '!_%' escape '!'", new String[]{str}, 0);
    }

    public final long g0(String str, String str2) {
        Object e;
        Throwable th;
        String str3 = str;
        String str4 = str2;
        f.N(str);
        f.N(str2);
        g();
        n();
        SQLiteDatabase t = t();
        t.beginTransaction();
        long j = 0;
        long w;
        try {
            String str5;
            String str6;
            StringBuilder stringBuilder = new StringBuilder(str2.length() + 32);
            stringBuilder.append("select ");
            stringBuilder.append(str4);
            stringBuilder.append(" from app2 where app_id=?");
            try {
                w = w(stringBuilder.toString(), new String[]{str3}, -1);
                str5 = "app2";
                str6 = HiAnalyticsConstant.BI_KEY_APP_ID;
                if (w == -1) {
                    ContentValues contentValues = new ContentValues();
                    contentValues.put(str6, str3);
                    contentValues.put("first_open_count", Integer.valueOf(0));
                    contentValues.put("previous_install_count", Integer.valueOf(0));
                    if (t.insertWithOnConflict(str5, null, contentValues, 5) == -1) {
                        d().f.c("Failed to insert column (got -1). appId", q3.s(str), str4);
                        t.endTransaction();
                        return -1;
                    }
                    w = 0;
                }
            } catch (SQLiteException e2) {
                e = e2;
                try {
                    d().f.d("Error inserting column. appId", q3.s(str), str4, e);
                    t.endTransaction();
                    w = j;
                    return w;
                } catch (Throwable th2) {
                    th = th2;
                    t.endTransaction();
                    throw th;
                }
            }
            try {
                ContentValues contentValues2 = new ContentValues();
                contentValues2.put(str6, str3);
                contentValues2.put(str4, Long.valueOf(1 + w));
                if (((long) t.update(str5, contentValues2, "app_id = ?", new String[]{str3})) == 0) {
                    d().f.c("Failed to update column (got 0). appId", q3.s(str), str4);
                    t.endTransaction();
                    return -1;
                }
                t.setTransactionSuccessful();
                t.endTransaction();
                return w;
            } catch (SQLiteException e3) {
                e = e3;
                j = w;
                d().f.d("Error inserting column. appId", q3.s(str), str4, e);
                t.endTransaction();
                w = j;
                return w;
            }
        } catch (SQLiteException e4) {
            e = e4;
            d().f.d("Error inserting column. appId", q3.s(str), str4, e);
            t.endTransaction();
            w = j;
            return w;
        } catch (Throwable th3) {
            th = th3;
            t.endTransaction();
            throw th;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:44:0x00c5  */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x00cd  */
    public final android.os.Bundle h0(java.lang.String r8) {
        /*
        r7 = this;
        r7.g();
        r7.n();
        r0 = 0;
        r1 = r7.t();	 Catch:{ SQLiteException -> 0x00b6, all -> 0x00b4 }
        r2 = "select parameters from default_event_params where app_id=?";
        r3 = 1;
        r3 = new java.lang.String[r3];	 Catch:{ SQLiteException -> 0x00b6, all -> 0x00b4 }
        r4 = 0;
        r3[r4] = r8;	 Catch:{ SQLiteException -> 0x00b6, all -> 0x00b4 }
        r1 = r1.rawQuery(r2, r3);	 Catch:{ SQLiteException -> 0x00b6, all -> 0x00b4 }
        r2 = r1.moveToFirst();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r2 != 0) goto L_0x002c;
    L_0x001d:
        r8 = r7.d();	 Catch:{ SQLiteException -> 0x00b2 }
        r8 = r8.n;	 Catch:{ SQLiteException -> 0x00b2 }
        r2 = "Default event parameters not found";
        r8.a(r2);	 Catch:{ SQLiteException -> 0x00b2 }
        r1.close();
        return r0;
    L_0x002c:
        r2 = r1.getBlob(r4);	 Catch:{ SQLiteException -> 0x00b2 }
        r3 = c.e.a.b.e.c.a1.M();	 Catch:{ IOException -> 0x009e }
        r2 = c.e.a.b.f.b.q9.x(r3, r2);	 Catch:{ IOException -> 0x009e }
        r2 = (c.e.a.b.e.c.a1.a) r2;	 Catch:{ IOException -> 0x009e }
        r2 = r2.l();	 Catch:{ IOException -> 0x009e }
        r2 = (c.e.a.b.e.c.u4) r2;	 Catch:{ IOException -> 0x009e }
        r2 = (c.e.a.b.e.c.a1) r2;	 Catch:{ IOException -> 0x009e }
        r7.m();	 Catch:{ SQLiteException -> 0x00b2 }
        r8 = r2.v();	 Catch:{ SQLiteException -> 0x00b2 }
        r2 = new android.os.Bundle;	 Catch:{ SQLiteException -> 0x00b2 }
        r2.<init>();	 Catch:{ SQLiteException -> 0x00b2 }
        r8 = r8.iterator();	 Catch:{ SQLiteException -> 0x00b2 }
    L_0x0052:
        r3 = r8.hasNext();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r3 == 0) goto L_0x009a;
    L_0x0058:
        r3 = r8.next();	 Catch:{ SQLiteException -> 0x00b2 }
        r3 = (c.e.a.b.e.c.c1) r3;	 Catch:{ SQLiteException -> 0x00b2 }
        r4 = r3.B();	 Catch:{ SQLiteException -> 0x00b2 }
        r5 = r3.M();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r5 == 0) goto L_0x0070;
    L_0x0068:
        r5 = r3.N();	 Catch:{ SQLiteException -> 0x00b2 }
        r2.putDouble(r4, r5);	 Catch:{ SQLiteException -> 0x00b2 }
        goto L_0x0052;
    L_0x0070:
        r5 = r3.K();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r5 == 0) goto L_0x007e;
    L_0x0076:
        r3 = r3.L();	 Catch:{ SQLiteException -> 0x00b2 }
        r2.putFloat(r4, r3);	 Catch:{ SQLiteException -> 0x00b2 }
        goto L_0x0052;
    L_0x007e:
        r5 = r3.F();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r5 == 0) goto L_0x008c;
    L_0x0084:
        r3 = r3.G();	 Catch:{ SQLiteException -> 0x00b2 }
        r2.putString(r4, r3);	 Catch:{ SQLiteException -> 0x00b2 }
        goto L_0x0052;
    L_0x008c:
        r5 = r3.I();	 Catch:{ SQLiteException -> 0x00b2 }
        if (r5 == 0) goto L_0x0052;
    L_0x0092:
        r5 = r3.J();	 Catch:{ SQLiteException -> 0x00b2 }
        r2.putLong(r4, r5);	 Catch:{ SQLiteException -> 0x00b2 }
        goto L_0x0052;
    L_0x009a:
        r1.close();
        return r2;
    L_0x009e:
        r2 = move-exception;
        r3 = r7.d();	 Catch:{ SQLiteException -> 0x00b2 }
        r3 = r3.f;	 Catch:{ SQLiteException -> 0x00b2 }
        r4 = "Failed to retrieve default event parameters. appId";
        r8 = c.e.a.b.f.b.q3.s(r8);	 Catch:{ SQLiteException -> 0x00b2 }
        r3.c(r4, r8, r2);	 Catch:{ SQLiteException -> 0x00b2 }
        r1.close();
        return r0;
    L_0x00b2:
        r8 = move-exception;
        goto L_0x00b8;
    L_0x00b4:
        r8 = move-exception;
        goto L_0x00cb;
    L_0x00b6:
        r8 = move-exception;
        r1 = r0;
    L_0x00b8:
        r2 = r7.d();	 Catch:{ all -> 0x00c9 }
        r2 = r2.f;	 Catch:{ all -> 0x00c9 }
        r3 = "Error selecting default event parameters";
        r2.b(r3, r8);	 Catch:{ all -> 0x00c9 }
        if (r1 == 0) goto L_0x00c8;
    L_0x00c5:
        r1.close();
    L_0x00c8:
        return r0;
    L_0x00c9:
        r8 = move-exception;
        r0 = r1;
    L_0x00cb:
        if (r0 == 0) goto L_0x00d0;
    L_0x00cd:
        r0.close();
    L_0x00d0:
        throw r8;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.h0(java.lang.String):android.os.Bundle");
    }

    public final void i0() {
        g();
        n();
        if (R()) {
            long a = l().h.a();
            Objects.requireNonNull((c) this.a.n);
            long elapsedRealtime = SystemClock.elapsedRealtime();
            if (Math.abs(elapsedRealtime - a) > ((Long) p.y.a(null)).longValue()) {
                l().h.b(elapsedRealtime);
                g();
                n();
                if (R()) {
                    SQLiteDatabase t = t();
                    r1 = new String[2];
                    Objects.requireNonNull((c) this.a.n);
                    r1[0] = String.valueOf(System.currentTimeMillis());
                    r1[1] = String.valueOf(c.B());
                    int delete = t.delete("queue", "abs(bundle_end_timestamp - ?) > cast(? as integer)", r1);
                    if (delete > 0) {
                        d().n.b("Deleted stale rows. rowsDeleted", Integer.valueOf(delete));
                    }
                }
            }
        }
    }

    public final long j0() {
        long j = -1;
        Cursor cursor = null;
        try {
            cursor = t().rawQuery("select rowid from raw_events order by rowid desc limit 1;", null);
            if (cursor.moveToFirst()) {
                j = cursor.getLong(0);
                cursor.close();
                return j;
            }
            cursor.close();
            return -1;
        } catch (SQLiteException e) {
            d().f.b("Error querying raw events", e);
            return j;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    public final boolean p() {
        return false;
    }

    public final void s() {
        n();
        t().setTransactionSuccessful();
    }

    public final SQLiteDatabase t() {
        g();
        try {
            return this.d.getWritableDatabase();
        } catch (SQLiteException e) {
            d().i.b("Error opening database", e);
            throw e;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x003b  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0034  */
    public final java.lang.String u() {
        /*
        r6 = this;
        r0 = r6.t();
        r1 = 0;
        r2 = "select app_id from queue order by has_realtime desc, rowid asc limit 1;";
        r0 = r0.rawQuery(r2, r1);	 Catch:{ SQLiteException -> 0x0025, all -> 0x0020 }
        r2 = r0.moveToFirst();	 Catch:{ SQLiteException -> 0x001e }
        if (r2 == 0) goto L_0x001a;
    L_0x0011:
        r2 = 0;
        r1 = r0.getString(r2);	 Catch:{ SQLiteException -> 0x001e }
        r0.close();
        return r1;
    L_0x001a:
        r0.close();
        return r1;
    L_0x001e:
        r2 = move-exception;
        goto L_0x0027;
    L_0x0020:
        r0 = move-exception;
        r5 = r1;
        r1 = r0;
        r0 = r5;
        goto L_0x0039;
    L_0x0025:
        r2 = move-exception;
        r0 = r1;
    L_0x0027:
        r3 = r6.d();	 Catch:{ all -> 0x0038 }
        r3 = r3.f;	 Catch:{ all -> 0x0038 }
        r4 = "Database error getting next bundle app id";
        r3.b(r4, r2);	 Catch:{ all -> 0x0038 }
        if (r0 == 0) goto L_0x0037;
    L_0x0034:
        r0.close();
    L_0x0037:
        return r1;
    L_0x0038:
        r1 = move-exception;
    L_0x0039:
        if (r0 == 0) goto L_0x003e;
    L_0x003b:
        r0.close();
    L_0x003e:
        throw r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.u():java.lang.String");
    }

    public final long v(e1 e1Var) throws IOException {
        g();
        n();
        f.N(e1Var.G1());
        byte[] i = e1Var.i();
        long t = m().t(i);
        ContentValues contentValues = new ContentValues();
        contentValues.put(HiAnalyticsConstant.BI_KEY_APP_ID, e1Var.G1());
        contentValues.put("metadata_fingerprint", Long.valueOf(t));
        contentValues.put("metadata", i);
        try {
            t().insertWithOnConflict("raw_events_metadata", null, contentValues, 4);
            return t;
        } catch (SQLiteException e) {
            d().f.c("Error storing raw event metadata. appId", q3.s(e1Var.G1()), e);
            throw e;
        }
    }

    public final long w(String str, String[] strArr, long j) {
        Cursor cursor = null;
        try {
            cursor = t().rawQuery(str, strArr);
            if (cursor.moveToFirst()) {
                long j2 = cursor.getLong(0);
                cursor.close();
                return j2;
            }
            cursor.close();
            return j;
        } catch (SQLiteException e) {
            d().f.c("Database error", str, e);
            throw e;
        } catch (Throwable th) {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    public final f x(long j, String str, long j2, boolean z, boolean z2, boolean z3, boolean z4, boolean z5) {
        f.N(str);
        g();
        n();
        String[] strArr = new String[]{str};
        f fVar = new f();
        Cursor cursor = null;
        try {
            SQLiteDatabase t = t();
            SQLiteDatabase sQLiteDatabase = t;
            cursor = sQLiteDatabase.query("apps", new String[]{"day", "daily_events_count", "daily_public_events_count", "daily_conversions_count", "daily_error_events_count", "daily_realtime_events_count"}, "app_id=?", new String[]{str}, null, null, null);
            if (cursor.moveToFirst()) {
                if (cursor.getLong(0) == j) {
                    fVar.b = cursor.getLong(1);
                    fVar.a = cursor.getLong(2);
                    fVar.c = cursor.getLong(3);
                    fVar.d = cursor.getLong(4);
                    fVar.e = cursor.getLong(5);
                }
                if (z) {
                    fVar.b += j2;
                }
                if (z2) {
                    fVar.a += j2;
                }
                if (z3) {
                    fVar.c += j2;
                }
                if (z4) {
                    fVar.d += j2;
                }
                if (z5) {
                    fVar.e += j2;
                }
                ContentValues contentValues = new ContentValues();
                contentValues.put("day", Long.valueOf(j));
                contentValues.put("daily_public_events_count", Long.valueOf(fVar.a));
                contentValues.put("daily_events_count", Long.valueOf(fVar.b));
                contentValues.put("daily_conversions_count", Long.valueOf(fVar.c));
                contentValues.put("daily_error_events_count", Long.valueOf(fVar.d));
                contentValues.put("daily_realtime_events_count", Long.valueOf(fVar.e));
                t.update("apps", contentValues, "app_id=?", strArr);
                cursor.close();
                return fVar;
            }
            d().i.b("Not updating daily counts, app is not known. appId", q3.s(str));
            cursor.close();
            return fVar;
        } catch (SQLiteException e) {
            d().f.c("Error updating daily counts. appId", q3.s(str), e);
            return fVar;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    public final f y(long j, String str, boolean z, boolean z2) {
        return x(j, str, 1, false, false, z, false, z2);
    }

    /* JADX WARNING: Removed duplicated region for block: B:63:0x013e  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0147  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0147  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x013e  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x013e  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0147  */
    public final c.e.a.b.f.b.l z(java.lang.String r26, java.lang.String r27) {
        /*
        r25 = this;
        r15 = r27;
        b.i.b.f.N(r26);
        b.i.b.f.N(r27);
        r25.g();
        r25.n();
        r0 = new java.util.ArrayList;
        r1 = "lifetime_count";
        r2 = "current_bundle_count";
        r3 = "last_fire_timestamp";
        r4 = "last_bundled_timestamp";
        r5 = "last_bundled_day";
        r6 = "last_sampled_complex_event_id";
        r7 = "last_sampling_rate";
        r8 = "last_exempt_from_sampling";
        r9 = "current_session_count";
        r1 = new java.lang.String[]{r1, r2, r3, r4, r5, r6, r7, r8, r9};
        r1 = java.util.Arrays.asList(r1);
        r0.<init>(r1);
        r18 = 0;
        r1 = r25.t();	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r2 = "events";
        r9 = 0;
        r3 = new java.lang.String[r9];	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r0 = r0.toArray(r3);	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r3 = r0;
        r3 = (java.lang.String[]) r3;	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r4 = "app_id=? and name=?";
        r0 = 2;
        r5 = new java.lang.String[r0];	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r5[r9] = r26;	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r10 = 1;
        r5[r10] = r15;	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r6 = 0;
        r7 = 0;
        r8 = 0;
        r14 = r1.query(r2, r3, r4, r5, r6, r7, r8);	 Catch:{ SQLiteException -> 0x0120, all -> 0x011e }
        r1 = r14.moveToFirst();	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r1 != 0) goto L_0x005a;
    L_0x0056:
        r14.close();
        return r18;
    L_0x005a:
        r4 = r14.getLong(r9);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r6 = r14.getLong(r10);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r11 = r14.getLong(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r0 = 3;
        r1 = r14.isNull(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r2 = 0;
        if (r1 == 0) goto L_0x0072;
    L_0x006f:
        r16 = r2;
        goto L_0x0078;
    L_0x0072:
        r0 = r14.getLong(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r16 = r0;
    L_0x0078:
        r0 = 4;
        r1 = r14.isNull(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r1 == 0) goto L_0x0082;
    L_0x007f:
        r0 = r18;
        goto L_0x008a;
    L_0x0082:
        r0 = r14.getLong(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r0 = java.lang.Long.valueOf(r0);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
    L_0x008a:
        r1 = 5;
        r8 = r14.isNull(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r8 == 0) goto L_0x0094;
    L_0x0091:
        r19 = r18;
        goto L_0x009e;
    L_0x0094:
        r19 = r14.getLong(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r1 = java.lang.Long.valueOf(r19);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r19 = r1;
    L_0x009e:
        r1 = 6;
        r8 = r14.isNull(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r8 == 0) goto L_0x00a8;
    L_0x00a5:
        r20 = r18;
        goto L_0x00b2;
    L_0x00a8:
        r20 = r14.getLong(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r1 = java.lang.Long.valueOf(r20);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r20 = r1;
    L_0x00b2:
        r1 = 7;
        r8 = r14.isNull(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r8 != 0) goto L_0x00cd;
    L_0x00b9:
        r21 = r14.getLong(r1);	 Catch:{ SQLiteException -> 0x00cb }
        r23 = 1;
        r1 = (r21 > r23 ? 1 : (r21 == r23 ? 0 : -1));
        if (r1 != 0) goto L_0x00c4;
    L_0x00c3:
        r9 = 1;
    L_0x00c4:
        r1 = java.lang.Boolean.valueOf(r9);	 Catch:{ SQLiteException -> 0x00cb }
        r21 = r1;
        goto L_0x00cf;
    L_0x00cb:
        r0 = move-exception;
        goto L_0x0123;
    L_0x00cd:
        r21 = r18;
    L_0x00cf:
        r1 = 8;
        r8 = r14.isNull(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        if (r8 == 0) goto L_0x00d9;
    L_0x00d7:
        r8 = r2;
        goto L_0x00de;
    L_0x00d9:
        r1 = r14.getLong(r1);	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r8 = r1;
    L_0x00de:
        r22 = new c.e.a.b.f.b.l;	 Catch:{ SQLiteException -> 0x011a, all -> 0x0114 }
        r1 = r22;
        r2 = r26;
        r3 = r27;
        r10 = r11;
        r12 = r16;
        r23 = r14;
        r14 = r0;
        r15 = r19;
        r16 = r20;
        r17 = r21;
        r1.m1453init(r2, r3, r4, r6, r8, r10, r12, r14, r15, r16, r17);	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
        r0 = r23.moveToNext();	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
        if (r0 == 0) goto L_0x010a;
    L_0x00fb:
        r0 = r25.d();	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
        r0 = r0.f;	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
        r1 = "Got multiple records for event aggregates, expected one. appId";
        r2 = c.e.a.b.f.b.q3.s(r26);	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
        r0.b(r1, r2);	 Catch:{ SQLiteException -> 0x0110, all -> 0x010e }
    L_0x010a:
        r23.close();
        return r22;
    L_0x010e:
        r0 = move-exception;
        goto L_0x0117;
    L_0x0110:
        r0 = move-exception;
        r14 = r23;
        goto L_0x0123;
    L_0x0114:
        r0 = move-exception;
        r23 = r14;
    L_0x0117:
        r18 = r23;
        goto L_0x0145;
    L_0x011a:
        r0 = move-exception;
        r23 = r14;
        goto L_0x0123;
    L_0x011e:
        r0 = move-exception;
        goto L_0x0145;
    L_0x0120:
        r0 = move-exception;
        r14 = r18;
    L_0x0123:
        r1 = r25.d();	 Catch:{ all -> 0x0142 }
        r1 = r1.f;	 Catch:{ all -> 0x0142 }
        r2 = "Error querying events. appId";
        r3 = c.e.a.b.f.b.q3.s(r26);	 Catch:{ all -> 0x0142 }
        r4 = r25.j();	 Catch:{ all -> 0x0142 }
        r5 = r27;
        r4 = r4.u(r5);	 Catch:{ all -> 0x0142 }
        r1.d(r2, r3, r4, r0);	 Catch:{ all -> 0x0142 }
        if (r14 == 0) goto L_0x0141;
    L_0x013e:
        r14.close();
    L_0x0141:
        return r18;
    L_0x0142:
        r0 = move-exception;
        r18 = r14;
    L_0x0145:
        if (r18 == 0) goto L_0x014a;
    L_0x0147:
        r18.close();
    L_0x014a:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.g.z(java.lang.String, java.lang.String):c.e.a.b.f.b.l");
    }
}
